import { defineStore } from 'pinia';
// 定义类型
interface MainStateType {
    isOperating: boolean,
    CreatingElement: null | object,
    CurrElementPosition: string[],
    elements: object[],
}
export const UseMainStore = defineStore('main', {
    state: (): MainStateType => ({
        isOperating: false,
        CreatingElement: null, // 正在插入的元素，需要通过绘制插入的文本，形状，线条
        CurrElementPosition: [''],
        elements: [],// 当前选中ppt上的所有元素
    }),
    actions: {
        setIsOperating(state: boolean) {
            this.isOperating = state
        },
        // 设置当前正在绘制的元素
        setCreatingElement(props: Object) {
            if (!props) {
                this.CreatingElement = null
                return false
            }
            this.CreatingElement = {
                ...this.CreatingElement,
                ...props
            }

        },
        // 设置当前插入元素的位置
        setCurrElementPosition(position: Array<string>) {
            this.CurrElementPosition = position
        },
        setElements(element: object) {
            this.elements.push(element);
        }
    }
})